﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EyFramework.SocketServer.OutData;
using WebSocketSharp;
using WebSocketSharp.Server;

namespace EyFramework.SocketServer.Behavior
{
    public class BaseBehavior : WebSocketBehavior
    {
        protected override void OnMessage(MessageEventArgs e)
        {
            Common.Logger.Info("【入参】：" + e.Data);
            string inData = e.Data;
            try
            {
                var outData = doBusiness(inData);
                Send(outData);
                Common.Logger.Info("【出参】：" + outData);
            }
            catch (Exception ex)
            {
                var outData = ReturnResult.Fail("交易失败:" + ex);
                Send(outData);
                Common.Logger.Info("【出参】：" + outData);
            }
        }

        public virtual string doBusiness(string inData)
        {
            return ReturnResult.Success("");
        }
    }
}